from turnited._config import *

import wsgiref.handlers
import os

from google.appengine.api import users
from google.appengine.ext import webapp


class InfoMainPage(webapp.RequestHandler):
    def get(self):
        write = self.response.out.write
        user = users.get_current_user()
        if user:
            name = user.nickname()
            email = user.email()
            url = users.create_logout_url(self.request.uri)
            linktext = "Logout"
        else:
            name = "<i>(unknown user)</i>"
            email = "<i>(unknown email)</i>"
            url = users.create_login_url(self.request.uri)
            linktext = "Login"
        write("<html><head></head><body>\n")
        write("<div><b>User:</b>%s <b>EMail:</b>%s</div>\n" % (name, email))
        write("<div><a href='%s'>%s</a></div>\n" % (url, linktext))
        write("</body></html>\n")
